package com.tangyee.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.tangyee.MainActivity;
import com.tangyee.home.HomeFragment;
import com.tangyee.person.PersonFragment;
import com.tangyee.MainActivity;
import com.tangyee.home.HomeFragment;
import com.tangyee.person.PersonFragment;
//页面适配器
public class FirstFragmentPagerAdapter extends FragmentPagerAdapter {
    private final int PAGER_COUNT = 2;
    //滑动页面数
    private HomeFragment homeFragment = null;
    private PersonFragment personFragment = null;

    public FirstFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
        homeFragment = new HomeFragment();
        personFragment = new PersonFragment();
    }

    @Override
    public int getCount() {
        return PAGER_COUNT;
    }

    @Override
    public Object instantiateItem(ViewGroup vg, int position) {
        return super.instantiateItem(vg, position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment = null;
        switch (position) {
            case MainActivity.PAGE_ONE:
                fragment =homeFragment;
                break;
            case MainActivity.PAGE_TWO:
                fragment = personFragment;
                break;
        }
        return fragment;
    }
}

